import Vue from "vue";
import Vuex from "vuex";
import createPersistedState from "vuex-persistedstate";

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    // pageInfo:window.localStorage.getItem('pageInfo')||{},
    pageInfo: {},
    userInfo: {},
    a: 0,
    bizType: "",
  },
  getters: {},
  mutations: {
    add(state, payload) {
      state.pageInfo = payload;
    },
    a_add(state, payload) {
      console.log(payload);
      state.a += payload;
    },
    bizType(state, payload) {
      state.pageInfo = payload;
    },

    // mp存储页面基本信息
    getPageInfo (state,payload){
      state.pageInfo = Object.assign({}, state.pageInfo, payload);
    },
    // 存储用户的信息
    getUserInfo (state,payload) {
      state.userInfo = Object.assign({}, state.userInfo, payload);
    }
  },
  actions: {},
  modules: {},
  plugins: [
    createPersistedState({
      storage: window.sessionStorage,
    }),
  ],
});
